<template>
  <div>
    <!--面包屑导航栏-->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>
        <router-link to="/home/reports">数据统计</router-link>
      </el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <!--卡片区域-->
    <el-card>
      <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
      <div id="main" style="width: 600px;height:400px;"></div>
    </el-card>
  </div>
</template>

<script>
import echarts from 'echarts'

export default {
  name: "report",
  data() {
    return {}
  },
  async mounted() {
    var myChart = echarts.init(document.getElementById('main'));

    //请求表格数据
    const {data: res} = await this.$http.get('reports/type/1')
    if(res.meta.status!==200)return this.$message.error('获取图标数据失败')
    this.$message.success('获取图表数据成功')
    console.log(res.data.xAxis[0].data)
    // 指定图表的配置项和数据
    var option = {
      title: {
        text: '用户来源'
      },
      tooltip: {},
      legend: {
        data: res.data.legend.data
      },
      xAxis: {data: res.data.xAxis[0].data},
      yAxis: {data: res.data.yAxis[0].data},
      series: res.data.series
    };
    myChart.setOption(option);
  },
  created() {
  }

}
</script>

<style scoped>

</style>
